package com.ruoyi.device.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.AlarmRuleLogMapper;
import com.ruoyi.device.domain.AlarmRuleLog;
import com.ruoyi.device.service.IAlarmRuleLogService;

import static com.ruoyi.common.security.utils.SecurityUtils.getLoginUser;

/**
 * 报警记录Service业务层处理
 * 
 * @author li
 * @date 2025-09-19
 */
@Service
public class AlarmRuleLogServiceImpl implements IAlarmRuleLogService 
{
    @Autowired
    private AlarmRuleLogMapper alarmRuleLogMapper;

    /**
     * 查询报警记录
     * 
     * @param id 报警记录主键
     * @return 报警记录
     */
    @Override
    public AlarmRuleLog selectAlarmRuleLogById(Long id)
    {
        return alarmRuleLogMapper.selectAlarmRuleLogById(id);
    }

    /**
     * 查询报警记录列表
     * 
     * @param alarmRuleLog 报警记录
     * @return 报警记录
     */
    @Override
    public List<AlarmRuleLog> selectAlarmRuleLogList(AlarmRuleLog alarmRuleLog)
    {
        return alarmRuleLogMapper.selectAlarmRuleLogList(alarmRuleLog);
    }

    /**
     * 新增报警记录
     * 
     * @param alarmRuleLog 报警记录
     * @return 结果
     */
    @Override
    public int insertAlarmRuleLog(AlarmRuleLog alarmRuleLog)
    {
        alarmRuleLog.setCreateBy(getLoginUser().getUsername());
        alarmRuleLog.setCreateTime(DateUtils.getNowDate());
        return alarmRuleLogMapper.insertAlarmRuleLog(alarmRuleLog);
    }

    /**
     * 修改报警记录
     * 
     * @param alarmRuleLog 报警记录
     * @return 结果
     */
    @Override
    public int updateAlarmRuleLog(AlarmRuleLog alarmRuleLog)
    {
        alarmRuleLog.setCreateBy(getLoginUser().getUsername());
        alarmRuleLog.setUpdateTime(DateUtils.getNowDate());
        return alarmRuleLogMapper.updateAlarmRuleLog(alarmRuleLog);
    }

    /**
     * 批量删除报警记录
     * 
     * @param ids 需要删除的报警记录主键
     * @return 结果
     */
    @Override
    public int deleteAlarmRuleLogByIds(Long[] ids)
    {
        return alarmRuleLogMapper.deleteAlarmRuleLogByIds(ids);
    }

    /**
     * 删除报警记录信息
     * 
     * @param id 报警记录主键
     * @return 结果
     */
    @Override
    public int deleteAlarmRuleLogById(Long id)
    {
        return alarmRuleLogMapper.deleteAlarmRuleLogById(id);
    }
}
